/* $Id: Team.java 39 2009-07-24 22:48:06Z h_m_r@gmx.de $ */
package org.jugger.tournament.model;

/**
 * @author Sven Hamer
 */
public class Team {
    private String name;
    private String city;
    private boolean isAdditionalTeam;
    private TeamStats currentTeamStats;

    public Team() {
    	this("", "");
    }

    public Team(String name, String city) {
    	this(name, city, false);
    }

    public Team(String name, String city, boolean isAdditionalTeam) {
        this.name = name;
        this.city = city;
        this.isAdditionalTeam = isAdditionalTeam;
        currentTeamStats = new TeamStats(this);
    }

    public String getName() {
        return name;
    }

    public String getCity() {
    	return city;
    }

    public boolean getIsAdditionalTeam() {
    	return isAdditionalTeam;
    }

    public void setName(String name) {
    	this.name = name;
    }

    public void setCity(String city) {
    	this.city = city;
    }

    public void setIsAdditionalTeam(boolean isAdditionalTeam) {
    	this.isAdditionalTeam = isAdditionalTeam;
    }

    public TeamStats getCurrentTeamStats() {
    	return currentTeamStats;
    }

    @Override
    public String toString() {
    	return name + " ("+city+")";
    }

    @Override
    public boolean equals(Object o) {
    	return o instanceof Team
    			&& o != null
    			&& getName().equals(((Team)o).getName())
    			&& getCity().equals(((Team)o).getCity())
    			&& getIsAdditionalTeam() == ((Team)o).getIsAdditionalTeam();
    }

    public boolean isValid() {
    	return name != null && !name.trim().isEmpty();
    }

    public void copyValuesFrom(Team otherTeam) {
    	name = otherTeam.getName();
    	city = otherTeam.getCity();
    	isAdditionalTeam = otherTeam.getIsAdditionalTeam();
    }
}
